﻿using JBeamLibrary.Tools;
using JBeamLibrary.VehicleParts.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JBeamLibrary.VehicleParts.Interfaces;
using Newtonsoft.Json.Linq;

namespace JBeamLibrary.VehicleParts.Elements
{
    public class Differential : VehicleElement
    {
        #region Properties

        public string WheelName1 { get; set; }

        public string WheelName2 { get; set; }

        public DifferentialType Type { get; set; }

        public DifferentialType State { get; set; }

        public int ClosedTorque { get; set; }

        public float EngineTorqueCoef { get; set; }

        #endregion

        #region CTORs

        public Differential()
        {
            Type = DifferentialType.Undefined;
            State = DifferentialType.Undefined;
            ClosedTorque = int.MinValue;
            EngineTorqueCoef = float.MinValue;
        }

        public Differential(string wheelName1, string wheelName2)
            : this()
        {
            WheelName1 = wheelName1;
            WheelName2 = wheelName2;
        }

        #endregion

        #region Methods

        public override IVehicleElement FromJBeam(JToken token)
        {
            return this;
        }

        public override JToken ToJBeam()
        {
            return new JArray
            {
                WheelName1.ToJBeam(),
                WheelName2.ToJBeam(),
                Type.ToStringOrEmpty().ToLowerInvariant().ToJBeam(),
                State.ToStringOrEmpty().ToLowerInvariant().ToJBeam(),
                ClosedTorque.ToJBeam(),
                EngineTorqueCoef.ToJBeam()
            };
        }

        #endregion
    }
}
